fName = GetSaveFileName types:"Core Engine model (*.bin)|*.bin|"\
	initialDir:(getDir #export)\
	historyCategory:"ExportTextFiles"
	
f = fopen fName "wb" 
countObjScene = 0
for tmpObj in objects do
(
	if classof tmpObj != Dummy then
	(
		countObjScene = countObjScene + 1
	)
)
writelong f countObjScene

for tmpObj in objects do
(
	if classof tmpObj != Dummy then
	(
		tmesh = snapshotAsMesh tmpObj	
		writelong f tmesh.numverts 
		writelong f tmesh.numtverts 
		writelong f tmesh.numfaces 
		if tmpObj.material != undefined then
		(
			writestring f (getFilenameFile tmpObj.material.diffusemap.filename + getFilenameType tmpObj.material.diffuseMap.filename)
		) 
		else
		(
			writestring f "undefined.bmp"
		)

		-- verts
		for i = 1 to tmesh.numverts do
		(
			v = (GetVert tmesh i)
			writefloat f v.x
			writefloat f v.y
			writefloat f v.z
			
			normal = (getNormal tmesh i)
			writefloat f normal.x
			writefloat f normal.y
			writefloat f normal.z
		) 
		
		-- tverts
		for i = 1 to tmesh.numtverts do
		(
			tv = (GetTVert tmesh i)
			writefloat f tv.x
			writefloat f tv.y
			writefloat f tv.Z
		)

		-- faces
		for i = 1 to tmesh.numfaces do
		(
			fc = (GetFace tmesh i)
			writelong f (fc.x - 1 as Integer)
			writelong f (fc.y - 1 as Integer)
			writelong f (fc.z - 1 as Integer)
			fc = (getTVFace tmesh i)
			writelong f (fc.x - 1 as Integer)
			writelong f (fc.y - 1 as Integer)
			writelong f (fc.z - 1 as Integer)
		) 
	)
)
fclose f